package com.ruoyi.gis.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.gis.domain.GisLayerGroup;
import com.ruoyi.gis.service.IGisLayerGroupService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 图层列表Controller
 *
 * @author rww
 * @date 2024-05-11
 */
@RestController
@RequestMapping("/gis/gisLayerGroup")
public class GisLayerGroupController extends BaseController
{
    @Autowired
    private IGisLayerGroupService gisLayerGroupService;

    /**
     * 查询图层列表列表
     */
    @GetMapping("/list")
    public TableDataInfo list(GisLayerGroup gisLayerGroup)
    {
        List<GisLayerGroup> list = gisLayerGroupService.selectGisLayerGroupList(gisLayerGroup);
        return getDataTable(list);
    }

    /**
     * 导出图层列表列表
     */
    @PreAuthorize("@ss.hasPermi('gis:gisLayerGroup:export')")
    @Log(title = "图层列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GisLayerGroup gisLayerGroup)
    {
        List<GisLayerGroup> list = gisLayerGroupService.selectGisLayerGroupList(gisLayerGroup);
        ExcelUtil<GisLayerGroup> util = new ExcelUtil<GisLayerGroup>(GisLayerGroup.class);
        util.exportExcel(response, list, "图层列表数据");
    }

    /**
     * 获取图层列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('gis:gisLayerGroup:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(gisLayerGroupService.selectGisLayerGroupById(id));
    }

    /**
     * 新增图层列表
     */
    @PreAuthorize("@ss.hasPermi('gis:gisLayerGroup:add')")
    @Log(title = "图层列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GisLayerGroup gisLayerGroup)
    {
        return toAjax(gisLayerGroupService.insertGisLayerGroup(gisLayerGroup));
    }

    /**
     * 修改图层列表
     */
    @PreAuthorize("@ss.hasPermi('gis:gisLayerGroup:edit')")
    @Log(title = "图层列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GisLayerGroup gisLayerGroup)
    {
        return toAjax(gisLayerGroupService.updateGisLayerGroup(gisLayerGroup));
    }

    /**
     * 删除图层列表
     */
    @PreAuthorize("@ss.hasPermi('gis:gisLayerGroup:remove')")
    @Log(title = "图层列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(gisLayerGroupService.deleteGisLayerGroupByIds(ids));
    }
}
